#include "glBuffer.h"
#include "glError.h"

bool glCreateBuffer(GL_BUFFER_DESC *pDesc, 
                    GL_SUBRESOURCE_DATA *pInitData, 
                    unsigned int *pBuffer)
{
  if (pDesc == NULL || pInitData == NULL || pBuffer == NULL)
    return false;

  unsigned int buffer = 0;
  glGenBuffers(1, &buffer);
  glBindBuffer(GL_ARRAY_BUFFER_ARB, buffer);
  glBufferData(GL_ARRAY_BUFFER_ARB, pDesc->ByteWidth, pInitData->pSysMem, pDesc->Usage);

  glBindBuffer(GL_ARRAY_BUFFER_ARB, 0);

  pBuffer[0] = buffer;

  return glCheckError(__LINE__, "glBuffer.cpp");
}

bool glDeleteBuffer(unsigned int *pBuffer)
{
	glDeleteBuffers(1, pBuffer);

	return glCheckError(__LINE__, "glBuffer.cpp");
}